package com.syni.mdd.yhd.common.all.config.pay.wxPay;

import com.syni.mdd.sjb.common.component.utils.common.spring.ApplicationContextHolder;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * App觅东东数据宝应用
 */

@Data
@Configuration
@DependsOn("wxPayBeanFactory")
public class AppMddDataTreasure {

    private final String appId = "wx4b0084c3c94f9abf";
    private final String appSecret = "";
    private final String mchId = "1563829591";
    private final String partnerKey = "z1SrP68ht18FExkDnuOLy7BsGaUdvyOh";
    private final String certPath = "/home/syniapp/mdd_cloud/global_config/apiclient_cert.p12";
    private final String domain = WxPayBeanFactory.DEV_BACK_URL + "/MDD_API/DSP_API";
    private String payNotifyUrl;
    private String refundNotifyUrl;
    private String appPayServiceCallBackUrl;

    @Bean(name = "MDD_DATA_TREASURE")
    public AppWxPayBean getAppWxPayBean(){
        AppWxPayBean appWxPayBean = new AppWxPayBean();
        appWxPayBean.setAppId(appId);
        appWxPayBean.setMchId(mchId);
        appWxPayBean.setPartnerKey(partnerKey);
        appWxPayBean.setCertPath(certPath);
        appWxPayBean.setDomain(domain);
        appWxPayBean.setPayNotifyUrl(appWxPayBean.getDomain() + "/wxPay/payNotify");
        appWxPayBean.setRefundNotifyUrl(appWxPayBean.getDomain() + "/wxPay/refundNotify");
        appWxPayBean.setAppPayServiceCallBackUrl(appWxPayBean.getDomain() + "/wxPay/appPayServicePayNotify");
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PRO)){
            appWxPayBean.setDomain("https://w.syni.com/MDD_API/DSP_API");
            appWxPayBean.setPayNotifyUrl(appWxPayBean.getDomain() + "/wxPay/payNotify");
            appWxPayBean.setRefundNotifyUrl(appWxPayBean.getDomain() + "/wxPay/refundNotify");
            appWxPayBean.setAppPayServiceCallBackUrl(appWxPayBean.getDomain() + "/wxPay/appPayServicePayNotify");
        }
        return appWxPayBean;
    }
}
